import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: ${NAME}
 * Package: ${PACKAGE_NAME}
 * Description:
 *
 * @Author 尚硅谷-宋红康
 * @Create 2025/8/11 10:51
 * @Version 1.0
 *///TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        List A = new ArrayList();
        A.add(1);
        A.add(2);
        A.add(3);

        List B = new ArrayList();
        B.add(2);
        B.add(3);
        B.add(4);


        List A1 = new ArrayList();
        A1.addAll(A);
        List A2 = new ArrayList();
        A2.addAll(A);

        List B1 = new ArrayList();
        B1.addAll(B);


        A.retainAll(B);

        B.removeAll(A1);
        A1.addAll(B);
        System.out.println("交集："+A);
        System.out.println("并集:"+A1);

        System.out.println("B有A无："+B);
        A2.removeAll(B1);
        System.out.println("A有B无："+A2);
    }
}